$(document).ready(function(){
	console.log("Settings.js is working");
	$("#change_em").click(function(){
		var email=$('#settings_email input[name="email"]').attr("value");
		var password=$('#settings_email input[name="password"]').attr("value");
		console.log(email);
		console.log(password);
		$.ajax({
			  type	: "GET",
			  url	: "/chengemail",
			  data	:{
				  nemail	:	email,
				  password	:	password
			  		}
			}).done(function(result){
				//console.log("result");
			});
	});
	$("#change_pass").click(function(){
		var o_password=$('#settings_password input[name="o_password"]').attr("value");
		var n_password=$('#settings_password input[name="n_password"]').attr("value");
		var confirm=$('#settings_password input[name="confirm"]').attr("value");
		console.log(o_password);
		console.log(n_password);
		console.log(confirm);
		$.ajax({
			  type	: "GET",
			  url	: "/chengpass",
			  data	:{
				  pass	:	o_password,
				  npass	:	n_password,
				  conf	:	confirm
			  		}
			}).done(function(result){
				if(result.error.type=="password")
					{$("#settings h4").html("Invalid new password");
					}else $("#settings h4").html("Password changed");
			});
	});
	$("#delete").click(function(){
		var password=$('#settings_delete input[name="password"]').attr("value");
		console.log(password);
		$.ajax({
			  type	: "GET",
			  url	: "/settings",
			  data	:{
				  pass	:	password
			  		}
			}).done(function(result){
				//console.log("result");
			});
	});
	$("#change_bd").click(function(){
		var day=$('#settings_birthday select[name="bday_day"]').attr("value");
		var month=$('#settings_birthday select[name="bday_month"]').attr("value");
		var year=$('#settings_birthday select[name="bday_year"]').attr("value");
		var password=$('#settings_birthday input[name="password"]').attr("value");
		console.log(day);
		console.log(month);
		console.log(year);
		console.log(password);
		$.ajax({
			  type	: "GET",
			  url	: "/settings",
			  data	:{
				  b_month	:	month,
				  b_day		:	day,
				  b_year	:	year
			  		}
			}).done(function(result){
				//console.log("result");
			});
	});
});